package com.hq.shcrm.controller;

import com.hq.shcrm.pojo.CRUDResult;
import com.hq.shcrm.pojo.CourseOrder;
import com.hq.shcrm.pojo.PageResult;
import com.hq.shcrm.service.ICourseOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author:huangqing
 * @create:2020-04-12-18:46
 */
@Controller
@RequestMapping("/courseorder")
public class CourseOrderController {

    @Autowired
    ICourseOrderService orderService;

    @RequestMapping("/list")
    public String list(){
        return "courseorder/list" ;
    }

    @RequestMapping("/listJson")
    @ResponseBody
    public PageResult<CourseOrder> listJson(int page,int limit){
        return orderService.findPageResult(null,page ,limit);
    }

    @RequestMapping("/add")
    public String add(){
        return "courseorder/add" ;
    }

    @RequestMapping("/save")
    @ResponseBody
    public CRUDResult save(CourseOrder order){
        CRUDResult result = new CRUDResult();
        //System.out.println(order);
        orderService.insert(order);
        return result;
    }

    @RequestMapping("/detail")
    public String detail(Model model,String order_id){
        CourseOrder courseOrder = orderService.findByOrderId(order_id);
        model.addAttribute(courseOrder);
        return "courseorder/detail";
    }

}
